<table class="common-table">
	<thead>
		<tr>
			<th>ID</th>
			<th>图片</th>
			<th>商品名称</th>
			<th>商品编号</th>
			<th>剩余数量</th>
			<th>价格</th>
			<th>修改时间</th>
			<th>修改人</th>
			<th width="30px;">状态</th>
			<th width="30px;">信息</th>
			<th width="30px;">图片</th>
			<th width="30px;">库存</th>
			<th width="30px;">价格</th>
			<th width="30px;">状态</th>
		</tr>
	</thead>
	<tbody>
		#{if commodities}
			#{list items:commodities, as:'commodity'}
			<tr>
				<th><a href="/admin/commodities/${commodity.id};edit">${commodity.id}</a></th>
				<td>
					<a href="/admin/commodities/${commodity.id};images">
						#{if commodity.images}
							#{list items:commodity.images, as:'image'}
								#{if image.sequence == 1}
								<img class="midImg" src="@{Attachments.show(image.image.id)}">
								#{/if}
							#{/list}
						#{/if}
						#{else}
						<img class="midImg" src="@{'public/images/favicon.png'}">
						#{/else}
					</a>
				</td>
				<td><a href="/admin/commodities/${commodity.id};edit">${commodity.name}</a></td>
				<td><a href="/admin/commodities/${commodity.id};edit">${commodity.SN}</a></td>
				<td>
					#{if commodity.onSaleStatus == models.Commodity.OnSaleStatus.ONSALE_LIMITED}
						${commodity.quantityLeft} ${commodity.unit}
					#{/if}
					#{if commodity.onSaleStatus == models.Commodity.OnSaleStatus.ONSALE_UNLIMITED}
						<font class="important_2">长期有货</font>
					#{/if}
					#{if commodity.onSaleStatus == models.Commodity.OnSaleStatus.OFFSALE}
						<font class="important">已下架</font>
					#{/if}
				</td>
				<td><font class="important_1">${commodity.price} 元</font></td>
				<td>${commodity.lastModifiedAt.format("yyyy-MM-dd hh:mm")}</td>
				<td>
					#{if commodity.lastModifiedByAdmin}
					${commodity.lastModifiedByAdmin.username}
					#{/if}
				</td>
				<td>
					#{if commodity.status == models.BaseEntity.Status.ENABLE}
					<font class="important_2">可用</font>
					#{/if}
					#{if commodity.status == models.BaseEntity.Status.DISABLED}
					<font class="important_1">不可用</font>
					#{/if}
				</td>
				<td>
					<a href="/admin/commodities/${commodity.id};edit" class="editer">
					[修改]
					</a>
				</td>
				<td>
					<a href="/admin/commodities/${commodity.id};images" class="editer">
					[修改]
					</a>
				</td>
				<td>
					<a href="/admin/commodities/${commodity.id};editQuantity" class="editer">
					[修改]
					</a>
				</td>
				<td>
					<a href="/admin/commodities/${commodity.id};editPrice" class="editer">
					[修改]
					</a>
				</td>
				<td>
					#{if commodity.status == models.BaseEntity.Status.ENABLE}
					<a href="javascript:updateStatus(${commodity.id}, 'DISABLED')" class="important_1">
					[禁用]
					</a>
					#{/if}
					#{if commodity.status == models.BaseEntity.Status.DISABLED}
					<a href="javascript:updateStatus(${commodity.id}, 'ENABLE')" class="important_2">
					[启用]
					</a>
					#{/if}
				</td>
			</tr>
			#{/list}
		#{/if}
		#{else}
		<tr>
			<td colspan="13">没找到结果。</td>
		</tr>
		#{/else}
	</tbody>
</table>
<div id="pager" style="font-size:1.3em;"></div>
<script language="javascript">
//初始化翻页控件。
function initialPager() {
	$("#pager").pager(
		{
			pagenumber: ${queryBean.currentPage}, 
			pagecount: ${queryBean.totalPage}, 
			totalcount: ${queryBean.totalQuantity},
			buttonClickCallback: PageClick
		}
	);
}
//翻页功能。
function PageClick(pageclickednumber) {
	$("#currentPage").val(pageclickednumber);
	reloadTable();
}
</script>